package com.kuang.single;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

// enum 是一个什么？枚举本身一个是一个Class类
public enum EnumSingle {

    //
    INSTANCE;

    public EnumSingle getInstance() {
        return INSTANCE;
    }
}

class Test{
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        EnumSingle instance1 = EnumSingle.INSTANCE;
        Constructor<EnumSingle> dc = EnumSingle.class.getDeclaredConstructor(String.class,int.class);
        dc.setAccessible(true);
        EnumSingle instance2 = dc.newInstance();
        System.out.println(instance1);

        // java.lang.NoSuchMethodException
        System.out.println(instance2);
    }
}
